<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ include file="/WEB-INF/jspf/taglibs.jspf"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="/styles/jquery-ui.css" >
<link rel="stylesheet" href="/styles/blueimp-gallery.css">
    <script type="text/javascript">
        localPath="page"
    </script>
<style type="text/css">
    #content { margin-bottom: 0px;}
</style>

</head>
<body>
<div class="p-h-md p-v bg-white box-shadow pos-rlt" id="top-title">
  <h3 class="no-margin have-btn-title">新建落地页</h3>
  <a href="/landing_pages/list" type="button" class="btn btn-sm btn-primary ng-click-active pull-right add-advert-btn-style">
    返回落地页列表
  </a>
</div>
<div class="p-md">
<input id="mainDomain" type="hidden" value="${mainDomain}"/>
<iframe id="iframeB"  name="iframeB" src="http://${diyFormDomain}/zen/front/<%= userContext.getId()%>/pages/${landingPageId}/edit" width="100%" scrolling="yes" frameborder="0"></iframe>
</div>

<div class="toolbar">
    <div class="btn-group">
      <div id="saveData" class="btn btn-primary">生成</div>
      <a id="preview" class="btn btn-primary" target="_blank" href="javascript:;">预览</a>
      <a id="backList" class="btn btn-primary" href="javascript:;">返回</a>
    </div>
</div>
<script src="/js/gallery/blueimp-gallery.js"></script>
<script src="/js/gallery/jquery.blueimp-gallery.js"></script>
<script src="/js/gallery/jquery.image-gallery.js"></script>

<script type="text/javascript">
    document.domain=$("#mainDomain").val();
    var h = $(window).height();
    var w = $(window).width();
    var headerh = $('#header').outerHeight(true);
    var titleh = $('#header').outerHeight(true);
    var toolbarh = $('.toolbar').outerHeight(true);
    var footerh = $('#footer').outerHeight(true);
    var endH = h-(headerh+titleh+toolbarh+footerh+70);

    function setHeight(h) {
        $('#iframeB').css('height',endH+'px');
       // var windowW = $(window).width();
       // // 当浏览器宽度大于1900减去头部50px导航
       // if (windowW >= 1900) {
       //   $('#iframeB').css('height',(h-100)+'px');
       // } else {
       //   // 当浏览器宽度小于1900减去头部以及底部
       //   $('#iframeB').css('height',(h-200)+'px');
       // }
    }
    $(function () {
        //生成
        $("#saveData").click(function(){
            var vue=document.getElementById("iframeB").contentWindow.MainFormBuilder;
            vue.saveData();
            console.log(vue)
           // var submitBtn = doc.find('.submit-btn').html();
            //console.log(submitBtn)
        })
        //预览
        $("#preview").click(function(){
            var vue=document.getElementById("iframeB").contentWindow.MainFormBuilder;
            var url=document.getElementById("iframeB").contentWindow.document.getElementById("preview").value
            vue.preview();
            window.open("http://${diyFormDomain}"+url)
        })
        $("#backList").click(function(){
            var vue=document.getElementById("iframeB").contentWindow.MainFormBuilder;
            vue.backList();
        })
        //返回

    });
</script>
</body>
</html>